package top.huhuiyu.springboot2.study.base;

import lombok.Data;

import java.io.Serializable;

/**
 * 基础应答结果
 *
 * @author 胡辉煜
 */
@Data
public class BaseResult implements Serializable {
  private static final long serialVersionUID = 1L;
  private int code;
  private String message;
  private boolean success;

  /**
   * 成功应答
   *
   * @param message 应答的消息
   * @return 成功应答结果
   */
  public static BaseResult ok(String message) {
    BaseResult result = new BaseResult();
    result.setSuccess(true);
    result.setMessage(message);
    result.setCode(200);
    return result;
  }

  /**
   * 失败应答
   *
   * @param message 应答的消息
   * @return 失败应答结果
   */
  public static BaseResult fail(String message) {
    BaseResult result = new BaseResult();
    result.setSuccess(false);
    result.setMessage(message);
    result.setCode(500);
    return result;
  }


}
